package com.lyn.seckill.common.error;

public enum EnumBusinessError implements CommonError{
    PARAMETER_VALIDATION_ERROR(10001,"参数不合法"),
    UNKNOWN_ERROR(10000,"未知错误"),
    // 2000开头为用户信息相关错误定义
    USER_NOT_EXIST(20001,"用户不存在"),
    USER_LOGIN_FAILURE(20002,"用户手机号不存在或密码错误"),
    USER_NOT_LOGIN(20003,"用户未登录"),
    //
    STOCK_NOT_ENOUGH(30001,"库存不足")
    ;

    EnumBusinessError(int errorCode, String errorMessage) {
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    private int errorCode;
    private String errorMessage;


    public static final String IS_LOGIN = "IS_LOGIN";
    public static final String LOGIN_USER = "LOGIN_USER";
    public static final Integer PROMO_NOT = 0;
    public static final Integer PROMO_NOT_START = 1;
    public static final Integer PROMO_ON_GOING = 2;
    public static final Integer PROMO_FINISHED = 3;

    @Override
    public int getErrorCode() {
        return this.errorCode;
    }

    @Override
    public String getErrorMessage() {
        return this.errorMessage;
    }

    @Override
    public CommonError setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
        return this;
    }
}
